--- title: "3、刷题统计" created: 2025-11-28 tags: - 算法 --- # 3、刷题统计 ## 题目 [刷题统计](https://www.lanqiao.cn/problems/2098/learning/) ![[image-5a0d0777.png]] ## 思路分析 最朴素的做法 一天一天往后枚举 发现是周末就+=b 其他就+=a 看刷题数大于n的时候是第几天 ```cpp #include using namespace std; int main() { long long a,b,n;cin>>a>>b>>n; long long cnt=1,sum=0; while(true){ if(cnt%7==6 || cnt%7==0) sum+=b; else sum+=a; if(sum>=n){ cout< using namespace std; typedef long long LL; int main() { LL a,b,n;cin>>a>>b>>n; int weekwork=a*5+b*2; //cout<<"一周做: "<0){ if(cnt%7==6 && cnt%7==0) remain-=b; else remain-=a; costdays++; cnt++; } cout< using namespace std; typedef long long LL; int main() { LL a, b, n; cin >> a >> b >> n; LL weekwork = a * 5 + b * 2; LL spendweek = n / weekwork; LL remain = n % weekwork; LL spendday = 0; if (remain == 0) { // 如果刚好在周末完成,无需额外天数 cout << 7 * spendweek; return 0; } if (remain <= 5 * a) { // 若剩下的题少于5*a道,在前五天完成 spendday = (remain + a - 1) / a; // 向上取整处理 } else { // 若剩下的题大于5*a道,在周末完成 spendday = 5; remain -= 5 * a; spendday += (remain + b - 1) / b; // 向上取整处理 } cout << 7 * spendweek + spendday; return 0; } ``` 注意a b n也要开long long ## 代码实现 ```cpp #include using namespace std; typedef long long LL; int main() { LL a, b, n; cin >> a >> b >> n; LL weekwork = a * 5 + b * 2; LL spendweek = n / weekwork; LL remain = n % weekwork; LL spendday = 0; if (remain == 0) { // 如果刚好在周末完成,无需额外天数 cout << 7 * spendweek; return 0; } if (remain <= 5 * a) { // 若剩下的题少于5*a道,在前五天完成 spendday = (remain + a - 1) / a; // 向上取整处理 } else { // 若剩下的题大于5*a道,在周末完成 spendday = 5; remain -= 5 * a; spendday += (remain + b - 1) / b; // 向上取整处理 } cout << 7 * spendweek + spendday; return 0; } ``` ## 同类题型 ## 视频讲解 --- ⬅️ [[2、顺子日期|2、顺子日期]] 🏠 [[00-刷题理模型]] ➡️ [[4、修剪灌木|4、修剪灌木]]